#include "card.h"

Card::Card()
{
	this->value = 0 ;
	this->suit = ' ' ;
}

Card::~Card()
{
	this->value = 0 ;
	this->suit = ' ' ;
}
void Card::Clear()
{
	this->value = 0 ;
	this->suit = ' ' ;
}

void Card::Swap( Card & obj ) 
{
	Card _ = *this ;
	*this = obj ;
	obj = _ ;
}

int& Card::GetValue()
{
	return this->value ;
}

char& Card::Suit()
{
	return this->suit ;
}

string Card::Value() const 
{
	switch( this->value)
	{
		case 1: return "2" ; break ;
		case 2: return "3" ; break ;
		case 3: return "4" ; break ;
		case 4: return "5" ; break ;
		case 5: return "6" ; break ;
		case 6: return "7" ; break ;
		case 7: return "8" ; break ;
		case 8: return "9" ; break ;
		case 9: return "10" ; break ;
		case 10: return "J" ; break ;
		case 11: return "Q" ; break ;
		case 12: return "K" ; break ;
		case 13: return "A" ; break ;
		default: return " " ; break ;
	}
}

string Card::Face()
{
	return Value() + Suit() ;
}

Card& Card::operator = ( const Card & obj )
{
	value = obj.value ;
	suit = obj.suit ;
	return *this ;
}

Card& Card::Set( int value, char suit )
{
	if( ( value > 0  && value < 14 ) && ( suit > -1 && suit < 4 ) )
	{
		this->value = value ;
		this->suit = suit + 3 ;
	}
	return *this ;
}

Card& Card::SetValue( int value ) 
{
	if( value > 0  && value < 14 )
		this->value = value ;
	return *this ;
}

Card& Card::SetSuit( char suit ) 
{
	if ( suit > -1 && suit < 4 ) 
		this->suit = suit + 3 ;
	return *this ;
}

bool Card::Empty() const 
{
	return( this->value == 0 && this->suit == ' ' ) ;
}

const bool Card::operator > ( const Card & obj ) 
{
	return this->value > obj.value ;
}

const bool Card::operator < ( const Card & obj ) 
{
	return this->value < obj.value ;
}

const bool Card::operator == ( const Card & obj ) 
{
	return ( this->value == obj.value && this->suit == obj.suit ) ;
}

const bool Card::operator != ( const Card & obj ) 
{
	return !( this->value == obj.value && this->suit == obj.suit ) ;
}